package com.yzt.message.widget.chatinput.utils;

import com.yzt.message.R;
import com.yzt.zhuju.richtext.entity.BigEmojiBean;
import com.yzt.zhuju.richtext.entity.EggEmojiBean;

import java.util.ArrayList;
import java.util.Random;


/**
 * Created by 李超军 on 2018/10/24.
 */

public class EmojiUtil {

    public static ArrayList<EggEmojiBean> getEggEmojiBeans() {
        ArrayList<EggEmojiBean> eggEmojiBeans = new ArrayList<>();
        try {
            EggEmojiBean bean = null;
            for (int i = 0; i < eggEmojiNames.length; i++) {
                bean = new EggEmojiBean(eggEmojiNames[i].substring(3, eggEmojiNames[i].length() - 1), eggEmojiNames[i], eggEmojiIconIds[i]);
                eggEmojiBeans.add(bean);
            }
        } catch (Exception e) {
            System.out.println("IreneBond EmojiUtils" + e.getMessage());
        }
        return eggEmojiBeans;
    }


    public static Integer getGifBigEmojiId(String emojiName) {
        int emojiId = 0;
        try {
            for (int i = 0; i < bigEmojiNames.length; i++) {
                if (emojiName.equals(bigEmojiNames[i])) {
                    emojiId = bigGifEmojiIconIds[i];
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return emojiId;
        }
    }

    public static ArrayList<BigEmojiBean> getBigEmojiBeans() {
        ArrayList<BigEmojiBean> eggEmojiBeans = new ArrayList<>();
        try {
            BigEmojiBean bean = null;
            for (int i = 0; i < bigEmojiNames.length; i++) {
                bean = new BigEmojiBean(bigEmojiNames[i].substring(1, bigEmojiNames[i].length() - 2), bigEmojiNames[i], bigEmojiIconIds[i]);
                eggEmojiBeans.add(bean);
            }
        } catch (Exception e) {
            System.out.println("IreneBond EmojiUtils" + e.getMessage());
        }
        return eggEmojiBeans;
    }


    public static final String[] bigEmojiNames = {
            "[爆灯大]",
            "[哈哈哈大]",
            "[666大]",
            "[谢谢大佬大]",
            "[暗示大]",
            "[喜欢你大]",
            "[赞大]",
            "[谢谢大]",
            "[好的大]",
            "[为什么大]",
            "[哇~大]",
            "[嘿嘿大]",
            "[无语大]",
            "[机智大]",
            "[哭泣大]",
            "[惊恐大]"
    };

    public static final Integer[] bigEmojiIconIds = {
//            R.drawable.big_emoij_15,
//            R.drawable.big_emoij_01,
//            R.drawable.big_emoij_14,
//            R.drawable.big_emoij_12,
//            R.drawable.big_emoij_16,
//            R.drawable.big_emoij_13,
//            R.drawable.big_emoij_10,
//            R.drawable.big_emoij_09,
//            R.drawable.big_emoij_02,
//            R.drawable.big_emoij_03,
//            R.drawable.big_emoij_05,
//            R.drawable.big_emoij_04,
//            R.drawable.big_emoij_07,
//            R.drawable.big_emoij_11,
//            R.drawable.big_emoij_08,
//            R.drawable.big_emoij_06
    };


    public static final Integer[] bigGifEmojiIconIds = {
//            R.drawable.big_emoij_gif_15,
//            R.drawable.big_emoij_gif_01,
//            R.drawable.big_emoij_gif_14,
//            R.drawable.big_emoij_gif_12,
//            R.drawable.big_emoij_gif_16,
//            R.drawable.big_emoij_gif_13,
//            R.drawable.big_emoij_gif_10,
//            R.drawable.big_emoij_gif_09,
//            R.drawable.big_emoij_gif_02,
//            R.drawable.big_emoij_gif_03,
//            R.drawable.big_emoij_gif_05,
//            R.drawable.big_emoij_gif_04,
//            R.drawable.big_emoij_gif_07,
//            R.drawable.big_emoij_gif_11,
//            R.drawable.big_emoij_gif_08,
//            R.drawable.big_emoij_gif_06
    };

    public static Integer getGifEggEmojiId(String emojiName) {
        int emojiId = 0;
        try {
            for (int i = 0; i < eggEmojiNames.length; i++) {
                if (emojiName.equals(eggEmojiNames[i])) {
                    emojiId = eggGifEmojiIconIds[i];
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return emojiId;
        }
    }

    public static Integer getEggEmojiId(String emojiName) {
        int emojiId = 0;
        try {
            for (int i = 0; i < eggEmojiNames.length; i++) {
                if (emojiName.equals(eggEmojiNames[i])) {
                    emojiId = eggEmojiIconIds[i];
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return emojiId;
        }
    }

    public static final String[] eggEmojiNames = {
            "[旦旦扣鼻屎]",
            "[旦旦呕吐]",
            "[旦旦卖萌]",
            "[旦旦大骂]",
            "[旦旦开心]",
            "[旦旦吐血]",
            "[旦旦有钱任性]",
            "[旦旦摔东西]",
            "[旦旦爱心]",
            "[旦旦惊讶]",
            "[旦旦发怒]",
            "[旦旦大笑]",
            "[旦旦大哭]",
            "[旦旦打人]",
            "[旦旦抱大腿]",
            "[旦旦等你哦]"
    };

    public static final Integer[] eggGifEmojiIconIds = {
//            R.drawable.egg_gif_emoji_0,
//            R.drawable.egg_gif_emoji_1,
//            R.drawable.egg_gif_emoji_2,
//            R.drawable.egg_gif_emoji_3,
//            R.drawable.egg_gif_emoji_4,
//            R.drawable.egg_gif_emoji_5,
//            R.drawable.egg_gif_emoji_6,
//            R.drawable.egg_gif_emoji_7,
//            R.drawable.egg_gif_emoji_8,
//            R.drawable.egg_gif_emoji_9,
//            R.drawable.egg_gif_emoji_10,
//            R.drawable.egg_gif_emoji_11,
//            R.drawable.egg_gif_emoji_12,
//            R.drawable.egg_gif_emoji_13,
//            R.drawable.egg_gif_emoji_14,
//            R.drawable.egg_gif_emoji_15
    };

    public static final Integer[] eggEmojiIconIds = {
//            R.drawable.egg_emoji_0,
//            R.drawable.egg_emoji_1,
//            R.drawable.egg_emoji_2,
//            R.drawable.egg_emoji_3,
//            R.drawable.egg_emoji_4,
//            R.drawable.egg_emoji_5,
//            R.drawable.egg_emoji_6,
//            R.drawable.egg_emoji_7,
//            R.drawable.egg_emoji_8,
//            R.drawable.egg_emoji_9,
//            R.drawable.egg_emoji_10,
//            R.drawable.egg_emoji_11,
//            R.drawable.egg_emoji_12,
//            R.drawable.egg_emoji_13,
//            R.drawable.egg_emoji_14,
//            R.drawable.egg_emoji_15
    };

    public static final Integer[] gameSeatOrderEmojiIconIds = {
//            R.drawable.game_seat_order_1,
//            R.drawable.game_seat_order_2,
//            R.drawable.game_seat_order_3,
//            R.drawable.game_seat_order_4,
//            R.drawable.game_seat_order_5,
//            R.drawable.game_seat_order_6,
//            R.drawable.game_seat_order_7,
//            R.drawable.game_seat_order_8
    };

    public static final Integer[] gameFingerGuessEmojiIconIds = {
//            R.drawable.game_finger_guess_1,
//            R.drawable.game_finger_guess_2,
//            R.drawable.game_finger_guess_3,
    };

    public static final Integer[] gameCoinGuessEmojiIconIds = {
//            R.drawable.game_coin_guess_1,
//            R.drawable.game_coin_guess_2,
    };

    public static final Integer[] gameGifEmojiIconIds = {
//            R.drawable.game_guess_coin,
//            R.drawable.game_guess_finger,
//            R.drawable.game_order_seat
    };

    public static final String[] gameGifEmojiNameIds = {
            "[游戏硬币]",
            "[游戏猜拳]",
            "[游戏排麦序]"
    };

    public static int getGameResultEmojiIconId(String gameName, int gameResult) {
        int gameResultEmojiIconId = 0;
        if (gameResult < 1) {
            return gameResultEmojiIconId;
        }
        switch (gameName) {
            case "[游戏硬币]":
                if (gameResult > 2) {
                    return gameResultEmojiIconId;
                }
                gameResultEmojiIconId = gameCoinGuessEmojiIconIds[gameResult - 1];
                break;
            case "[游戏猜拳]":
                if (gameResult > 3) {
                    return gameResultEmojiIconId;
                }
                gameResultEmojiIconId = gameFingerGuessEmojiIconIds[gameResult - 1];
                break;
            case "[游戏排麦序]":
                if (gameResult > 8) {
                    return gameResultEmojiIconId;
                }
                gameResultEmojiIconId = gameSeatOrderEmojiIconIds[gameResult - 1];
                break;
        }
        return gameResultEmojiIconId;
    }

    public static int getGameGifEmojiId(String gameName) {
        int gameGifEmojiId = 0;
        for (int i = 0; i < gameGifEmojiNameIds.length; i++) {
            if (gameName.equals(gameGifEmojiNameIds[i])) {
                gameGifEmojiId = gameGifEmojiIconIds[i];
            }
        }
        return gameGifEmojiId;
    }

    public static int getGameResult(String gameName) {
        int gameResult = -1;
        switch (gameName) {
            case "[游戏硬币]":
                gameResult = getGameResult(2);
                break;
            case "[游戏猜拳]":
                gameResult = getGameResult(3);
                break;
            case "[游戏排麦序]":
                gameResult = getGameResult(8);
                break;
        }
        return gameResult;
    }

    public static int getGameResult(int range) {
        return new Random().nextInt(range) + 1;
    }

}
